// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search;

public sealed partial class RegexOptions
{
	/// <summary>
	/// <para>Optional operators for the regular expression.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("flags")]
	public object? Flags { get; set; }

	/// <summary>
	/// <para>Maximum number of automaton states required for the query.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("max_determinized_states")]
	public int? MaxDeterminizedStates { get; set; }
}

public sealed partial class RegexOptionsDescriptor : SerializableDescriptor<RegexOptionsDescriptor>
{
	internal RegexOptionsDescriptor(Action<RegexOptionsDescriptor> configure) => configure.Invoke(this);

	public RegexOptionsDescriptor() : base()
	{
	}

	private object? FlagsValue { get; set; }
	private int? MaxDeterminizedStatesValue { get; set; }

	/// <summary>
	/// <para>Optional operators for the regular expression.</para>
	/// </summary>
	public RegexOptionsDescriptor Flags(object? flags)
	{
		FlagsValue = flags;
		return Self;
	}

	/// <summary>
	/// <para>Maximum number of automaton states required for the query.</para>
	/// </summary>
	public RegexOptionsDescriptor MaxDeterminizedStates(int? maxDeterminizedStates)
	{
		MaxDeterminizedStatesValue = maxDeterminizedStates;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (FlagsValue is not null)
		{
			writer.WritePropertyName("flags");
			JsonSerializer.Serialize(writer, FlagsValue, options);
		}

		if (MaxDeterminizedStatesValue.HasValue)
		{
			writer.WritePropertyName("max_determinized_states");
			writer.WriteNumberValue(MaxDeterminizedStatesValue.Value);
		}

		writer.WriteEndObject();
	}
}